package com.ymatou.iapi.godfreight.testcase;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godfreight.parameter.CalcOrderFreightBean;
import com.ymatou.iapi.godfreight.parameter.OrderDto;
import com.ymatou.iapi.godfreight.parameter.ProductDto;
import com.ymatou.iapi.godfreight.service.CalcOrderFreightCall;
import com.ymatou.iapi.godfreightmgr.parameter.CreateFreightDetailDto;
import com.ymatou.iapi.godfreightmgr.parameter.CreateFreightDto;
import com.ymatou.iapi.godfreightmgr.parameter.CreateFreightTemplateBean;
import com.ymatou.iapi.godfreightmgr.parameter.EditFreightTemplateBean;
import com.ymatou.iapi.godfreightmgr.service.CreateFreightTemplateCall;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.freight_template;
import com.ymttest.database.sqlwapper.godfreight.freight_templateWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.TestDataManager;

/**
*代购神器计算订单运费
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CalcOrderFreight{
	private static CalcOrderFreightBean bean;
	private static CalcOrderFreightCall call;
	private static freight_templateWapper freight_templateWapper=new freight_templateWapper();;
	//渠道商
	private static int sellerId1 = AgentUsers.rootUserId;
	private static String sellerName1 = "NickautoTest";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("代购神器计算订单运费");
	}

	@Before
	public void caseUp() throws Exception {
		bean=new CalcOrderFreightBean();
		call=new CalcOrderFreightCall();
		//渠道
		UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
		int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
		createmchBean createmchbean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
		GodmchManageCallService.createmchCallForChannel(createmchbean);
		sellerId1=userId_channl;
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	/**
	 * 初始化运费模板  目前日本 模版金额不可以有
	 * @param firstNumOrWeight
	 * @param firstFee
	 * @param addNumOrWeight
	 * @param addFee
	 * @param calcModel
	 * @return
	 * @throws Exception
	 */
	private CreateFreightTemplateBean initCreateFreightTemplate(BigDecimal firstNumOrWeight,BigDecimal firstFee,BigDecimal addNumOrWeight,BigDecimal addFee,int calcModel) throws Exception {
		Logger.comment("###### 创建商户 #######");
		UserCreateBean usercreateBean = DGUserCallService.initSellerUsercreateBean();
		int mchId = DGUserCallService.UserCreateCall(usercreateBean);
		createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
		GodmchManageCallService.createmchCallForChannel(createmchBean);
		Logger.comment("###### 商户id #######  "+mchId);
		CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(mchId,calcModel,1);
		createBean.setPolicyModel(1);//1 累加 2 组合
		
		CreateFreightDetailDto createFreightDetailDto=createBean.getMainFreight().getTemplateItems().get(0);
		if(calcModel==1) //计件
		{
			createFreightDetailDto.setFirstNum(Integer.parseInt(firstNumOrWeight.toString()));//首件数量
			createFreightDetailDto.setFirstFee(firstFee);//续件数2
			createFreightDetailDto.setAddNum(Integer.parseInt(addNumOrWeight.toString()));//续增件
			createFreightDetailDto.setAddFee(addFee);//续增费
		}
		//计重
		else if(calcModel==2) //计重
		{
			createFreightDetailDto.setFirstWeight(firstNumOrWeight);//首重数量
			createFreightDetailDto.setFirstFee(firstFee);//首续数量
			createFreightDetailDto.setAddWeight(addNumOrWeight);//首重运费
			createFreightDetailDto.setAddFee(addFee);// 续重 运费
		}
		return createBean;
	}
	/**
	 * 设置主模板
	 * @param firstNumOrWeight 首件/首重数量
	 * @param firstFee 续件/首重 数量
	 * @param addNumOrWeight 续增件/续增费
	 * @param addFee 续增费
	 * @param calcModel 计费方式 1 按件 2 按重
	 * @param sellerId 买家id
	 * @param saleMode 1-零售直销和代理, 2-直销代理共享
	 * @return 
	 * @throws Exception 
	 */
	private Pair<Integer, Integer> setCreateFreightTemplate(BigDecimal firstNumOrWeight,BigDecimal firstFee,BigDecimal addNumOrWeight,BigDecimal addFee,int calcModel,int... sellerId) throws Exception
	{
		Logger.comment("###### 创建商户 #######");
		UserCreateBean usercreateBean = DGUserCallService.initSellerUsercreateBean();
		int mchId = DGUserCallService.UserCreateCall(usercreateBean);
		createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
		GodmchManageCallService.createmchCallForChannel(createmchBean);
		Logger.comment("###### 商户id #######  "+mchId);
		CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(mchId,calcModel,1);
		createBean.setPolicyModel(1);//1 累加 2 组合
		if(sellerId.length>0)
			createBean.setSellerId(sellerId[0]);
		
		CreateFreightDetailDto createFreightDetailDto=createBean.getMainFreight().getTemplateItems().get(0);
		if(calcModel==1) //计件
		{
			createFreightDetailDto.setFirstNum(Integer.parseInt(firstNumOrWeight.toString()));//首件数量
			createFreightDetailDto.setFirstFee(firstFee);//续件数2
			createFreightDetailDto.setAddNum(Integer.parseInt(addNumOrWeight.toString()));//续增件
			createFreightDetailDto.setAddFee(addFee);//续增费
		}
		//计重
		else if(calcModel==2) //计重
		{
			createFreightDetailDto.setFirstWeight(firstNumOrWeight);//首重数量
			createFreightDetailDto.setFirstFee(firstFee);//首续数量
			createFreightDetailDto.setAddWeight(addNumOrWeight);//首重运费
			createFreightDetailDto.setAddFee(addFee);// 续重 运费
		}
		
		String templateId =GodfreightmgrService.CreateFreightTemplate(createBean);
		Pair<Integer, Integer> templateIdAndSeller =Pair.of(Integer.parseInt(templateId),
				Integer.parseInt(String.valueOf(createBean.getSellerId())));
	    return templateIdAndSeller;
	}
	/**
	 * 设置代理模板 主模板默认
	  * @param firstNumOrWeight 首件/首重数量
	 * @param firstFee 续件/首重 数量
	 * @param addNumOrWeight 续增件/续增费
	 * @param addFee 续增费
	 * @param calcModel 计费方式 1 按件 2 按重
	 * @param sellerId 买家id
	 * @param calcModel 计费方式 1 按件 2 按重
	 * @return
	 * @throws Exception
	 */
	private Pair<Integer, Integer> setAgentFreightTemplate(BigDecimal firstNumOrWeight,BigDecimal firstFee,BigDecimal addNumOrWeight,BigDecimal addFee,int calcModel,int... sellerId) throws Exception
	{
		Logger.comment("###### 创建商户 #######");
		UserCreateBean usercreateBean = DGUserCallService.initSellerUsercreateBean();
		int mchId = DGUserCallService.UserCreateCall(usercreateBean);
		createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
		GodmchManageCallService.createmchCallForChannel(createmchBean);
		Logger.comment("###### 商户id #######  "+mchId);
		CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(mchId,calcModel,1);
		createBean.setPolicyModel(1);//1 累加 2 组合
		if(sellerId.length>0)
			createBean.setSellerId(sellerId[0]);
		
		CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);
		if(calcModel==1) //计件
		{
			createFreightDetailDto.setFirstNum(Integer.parseInt(firstNumOrWeight.toString()));//首件数量
			createFreightDetailDto.setFirstFee(firstFee);//续件数2
			createFreightDetailDto.setAddNum(Integer.parseInt(addNumOrWeight.toString()));//续增件
			createFreightDetailDto.setAddFee(addFee);//续增费
		}
		//计重
		else if(calcModel==2) //计重
		{
			createFreightDetailDto.setFirstWeight(firstNumOrWeight);//首重数量
			createFreightDetailDto.setFirstFee(firstFee);//首续数量
			createFreightDetailDto.setAddWeight(addNumOrWeight);//首重运费
			createFreightDetailDto.setAddFee(addFee);// 续重 运费
		}
		
				
		String templateId =GodfreightmgrService.CreateFreightTemplate(createBean);
		Pair<Integer, Integer> templateIdAndSeller =Pair.of(Integer.parseInt(templateId),
				Integer.parseInt(String.valueOf(createBean.getSellerId())));
	    return templateIdAndSeller;
	}
	//设置商品
	private List<ProductDto> setProduct(int templateId)
	{
		ProductDto product=new ProductDto();
		List<ProductDto> productDtos =new ArrayList();
		product.setproductId(TestDataManager.getRandomNum(5));
		product.setCatalogId(TestDataManager.getRandomNum(5));
		product.setperWeight(new BigDecimal("1"));//每件商品重量
		product.setQuantity(1);//购买数量
		product.setSaleMode(1);//销售方式 1-直销 2-代理 3-共享
		product.setTemplateId(templateId);//从创建模版中获取
		productDtos.add(product);
		return productDtos;
	}
	//设置订单
	private List<OrderDto> setOrder(List<ProductDto> productDtos)
	{
		bean.setAppId(TestDataManager.getRandomNum(5));
		bean.setRequestId(TestDataManager.getRandomNum(5));
		
		OrderDto order=new OrderDto();
		List<OrderDto> orderDtos =new ArrayList();
		order.setOrderNo(Integer.parseInt(TestDataManager.getRandomNum(5)));
		order.setSellerId(Integer.parseInt(TestDataManager.getRandomNum(5)));
		order.setProductDtos(productDtos);
		orderDtos.add(order);
		return orderDtos;
	}
	//设置计算运费请求
	private List<OrderDto>  setCalcOrderFreight(int templateId)
	{

		List<ProductDto> productDtos=setProduct(templateId);
		
		List<OrderDto> orderDtos=setOrder(productDtos);
		bean.setDeliveryCity("上海");
		return  orderDtos;
	}
    //检查返回结果
	private void check_verify(List<BigDecimal> act_freight,BigDecimal totalFreight) throws JSONException
	{
		Logger.verifyEquals("true", call.getSuccess(), "验证返回Success成功");
		OrderDto act_order=bean.getOrderDtos().get(0);
		List<ProductDto> act_productList=act_order.getProductDtos();
		OrderDto exp_order=call.getOrderDtos().getOrderDtos().get(0);

		Logger.verifyEquals(totalFreight, exp_order.getfreight(), "验证返回OrderDto中的freight字段");//总运费
		Logger.verifyEquals(act_order.getOrderNo(), exp_order.getOrderNo(), "验证返回OrderDto中的OrderNo字段");
		Logger.verifyEquals(act_order.getSellerId(), exp_order.getSellerId(), "验证返回OrderDto中的SellerId字段");
		
    	BigDecimal total_reight=new BigDecimal(0);//保存前几个商品的运费
        for(int i=0;i<exp_order.getProductDtos().size();i++){
        	ProductDto exp_product=exp_order.getProductDtos().get(i);//单个商品
        	if(exp_order.getProductDtos().size()>i+1)
        	{
        		BigDecimal freight=new BigDecimal(act_freight.get(i).stripTrailingZeros().toPlainString()).setScale( 0, BigDecimal.ROUND_DOWN );
        		total_reight=total_reight.add(freight);
        		Logger.verifyEquals(freight.stripTrailingZeros().toPlainString(), exp_product.getFreight().toPlainString(), "验证返回ProductDto中的Freight字段");
        		Logger.comment("freight:  "+freight);
        	}else//最后一个公摊
        	{
        		Logger.verifyEquals(totalFreight.subtract(total_reight).stripTrailingZeros().toPlainString(), exp_product.getFreight().toPlainString(), "验证返回ProductDto中的最后一个公摊运费Freight字段");
        		Logger.comment("最后个商品分摊sub_totalFreight:  "+totalFreight.subtract(total_reight));
        	}
        	
			Logger.verifyEquals(act_productList.get(i).getproductId(), exp_product.getproductId(), "验证返回ProductDto中的productId字段");
			Logger.verifyEquals(act_productList.get(i).getCatalogId(), exp_product.getCatalogId(), "验证返回ProductDto中的CatalogId字段");
			Logger.verifyEquals(act_productList.get(i).getperWeight(), exp_product.getperWeight(), "验证返回ProductDto中的perWeight字段");
			Logger.verifyEquals(act_productList.get(i).getQuantity(), exp_product.getQuantity(), "验证返回ProductDto中的Quantity字段");
			Logger.verifyEquals(act_productList.get(i).getSaleMode(), exp_product.getSaleMode(), "验证返回ProductDto中的SaleMode字段");
			Logger.verifyEquals(act_productList.get(i).getTemplateId(), exp_product.getTemplateId(), "验证返回ProductDto中的TemplateId字段");
			
			freight_template template=freight_templateWapper.selectByPrimaryKey(exp_product.getTemplateId());
			Logger.verifyEquals(template.getCurrency(), exp_product.getFreightCurrency(), "验证返回ProductDto中的FreightCurrency字段");
        }
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_001() {
		Logger.start(true,"单商品-按件-商品累加【商品1件,模版:首1件2元,每增1件2元,返回运费2(首运费)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_002() {
		Logger.start(true,"单商品-按件-商品累加【商品3件,模版:首2件2元,每增1件3元,返回运费5(1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("5");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_003() {
		Logger.start(true,"单商品-按件-商品累加【商品3件,模版:首2件2元,每增2件2元,返回运费4(少于1倍续增,按1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("4");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_004() {
		Logger.start(true,"单商品-按件-商品累加【商品6件,模版:首3件2元,每增2件2元,返回运费6(少于2倍续增,按2倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(6);
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("6");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_004_1() {
		Logger.start(true,"单商品-按件-商品累加【商品2件,模版:首2件2元,每增1件2元,返回运费2(首运费)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(2);
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_005() {
		Logger.start(true,"单商品-按重量-商品累加【商品1KG,模版:首1KG2元,每增1KG2元,返回运费2(首运费)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("1"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_006() {
		Logger.start(true,"单商品-按重量-商品累加【商品5KG,模版:首3KG2元,每增1KG3元,返回运费8(2倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("8");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_007() {
		Logger.start(true,"单商品-按重量-商品累加【商品3KG,模版:首2KG2元,每增2KG5元,返回运费7(少于1倍续增重量,按1倍续增重量)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("5"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("3"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008() {
		Logger.start(true,"单商品-按重量-商品累加【商品6KG,模版:首3KG2元,每增2KG7元,返回运费16(少于2倍续增重,按2倍续增重)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("7"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("6"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("16");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008_1() {
		Logger.start(true,"单商品-按重量-商品累加【商品2KG,模版:首2KG3元,每增1KG2元,返回运费3(首运费)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("3"),new BigDecimal("1"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("3");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008_2() {
		Logger.start(true,"单商品-按重量-商品累加【商品2.3KG,模版:首1.4KG2元,每增1.2KG3元,返回运费5(少于1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1.4"),new BigDecimal("2"),new BigDecimal("1.2"),new BigDecimal("3"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2.3"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("5");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008_3() {
		Logger.start(true,"单商品-按重量-商品累加-重量和价格都是小时【商品2.3KG,模版:首1.4KG2.1元,每增1.2KG3.4元,返回运费5.5(少于1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1.4"),new BigDecimal("2.1"),new BigDecimal("1.2"),new BigDecimal("3.4"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2.3"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("5.5");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_008_4() {
		Logger.start(true,"单商品-按重量-商品累加-重量和价格都是小时,且两位【商品2.3KG,模版:首1.4KG2.15元,每增1.2KG3.44元,返回运费5.59(少于1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1.4"),new BigDecimal("2.15"),new BigDecimal("1.2"),new BigDecimal("3.44"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2.3"));
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("5.59");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_009() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品2件,B商品11件-模版:首2件3元,每增3件4元,返回运费3+【(13-2)/3】*4=19元,一共19(A商品:首运费 3元,B商品:续增件3倍 )】");
		try {
			
			//org.junit.Assert.fail();
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("3"),new BigDecimal("3"),new BigDecimal("4"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setQuantity(2);
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(11);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			//orderList.add(orderList.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("19");//总运费

		    BigDecimal rate=new BigDecimal("2").divide(new BigDecimal("13"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_010() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品1件,B商品3件-模版:首1件2元,每增1件3元,返回运费2+【(4-1)/1】*3=11(A商品:首运费 ,B商品:续增件2倍)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(3);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			//orderList.add(orderList.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("11");//总运费

		    BigDecimal rate=new BigDecimal("1").divide(new BigDecimal("4"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_011() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品1件,B商品3件-模版:首1件2元,每增2件2元,返回运费2+【(4-1)/1】*2=6(A商品:首运费,B商品:少于1倍续增,按1倍续增）) 】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(3);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			//orderList.add(orderList.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("6");//总运费

		    BigDecimal rate=new BigDecimal("1").divide(new BigDecimal("4"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_012() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品7件,B商品7件-模版:首3件2元,每增2件2元,返回运费2+【(14-2)/2】*2=14)】(A商品:2倍续增,B商品:2倍续增 ");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setQuantity(7);
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(7);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("14");//总运费

		    BigDecimal rate=new BigDecimal("7").divide(new BigDecimal("14"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_013() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品6件,B商品6件-模版:首3件2元,每增2件2元,返回运费 2+【(12-3)/2】*2=12(A商品:少于2倍续增,按2倍续增,B商品:少于2倍续增,按2倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(6);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(6);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("12");//总运费

		    BigDecimal rate=new BigDecimal("7").divide(new BigDecimal("14"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_014() {
		Logger.start(true,"多商品-都按件-同模版-商品累加【A商品3件,B商品4件-模版:首1件2元,每增2件2元,返回运费2+【(7-1)/2】*2=8(A商品:2倍续增 ,B商品:少于2倍续增件,按2倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(4);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("8");//总运费

		    BigDecimal rate=new BigDecimal("3").divide(new BigDecimal("7"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_015() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品5KG,B商品8KG-模版:首5KG2元,每增1KG3元,返回运费2+【(13-5)/1】*3=26(A商品:首运费 2元,B商品:续增3倍)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("5"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("8"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("26");//总运费

		    BigDecimal rate=new BigDecimal("5").divide(new BigDecimal("13"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_016() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品4KG,B商品6KG-模版:首4KG2元,每增1KG2元,返回运费2+【(10-4)/1】*2=14(A商品:首运费 2元,B商品:续增2倍)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("4"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("4"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("6"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("14");//总运费

		    BigDecimal rate=new BigDecimal("4").divide(new BigDecimal("10"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_017() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品1KG,B商品2KG-模版:首1KG2元,每增2KG2元,返回运费2+【(3-1)/2】*2=4 A商品:首运费 2元,B商品:少于1倍续增,按1倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("1"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("4");//总运费

		    BigDecimal rate=new BigDecimal("1").divide(new BigDecimal("3"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_018() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品6KG,B商品6KG-模版:首4KG2元,每增2KG2元,返回运费 2+【(12-4)/2】*2=10(A商品:2倍续增 ,B商品:2倍续增 】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("4"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("6"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("6"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("10");//总运费

		    BigDecimal rate=new BigDecimal("6").divide(new BigDecimal("12"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_019() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品4KG,B商品4KG-模版:首1KG2元,每增2KG3元,返回运费 2+【(8-1)/2】*3=14(A商品:少于2倍续增,按2倍续增,B商品:少于2倍续增,按2倍续增】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("3"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("4"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("4"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("14");//总运费

		    BigDecimal rate=new BigDecimal("4").divide(new BigDecimal("8"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_020() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加【A商品5KG,B商品4KG-模版:首1KG2元,每增2KG3元,返回运费 2+【(9-1)/2】*3=14(A商品:2倍续增,B商品::少于2倍续增,按2倍续增)】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("3"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("4"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("14");//总运费

		    BigDecimal rate=new BigDecimal("5").divide(new BigDecimal("9"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_020_1() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加-重量为小时【A商品3.7KG,B商品4.1KG-模版:首1.5KG2元,每增2.3KG2元,返回运费 2+【(7.8-1.5)/2.3】*2=8(A商品:少于1倍续增 ,B商品:少于2倍续增,按2倍续增 )】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1.5"),new BigDecimal("2"),new BigDecimal("2.3"),new BigDecimal("2"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("3.7"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("4.1"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("8");//总运费

		    BigDecimal rate=new BigDecimal("3.7").divide(new BigDecimal("7.8"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_020_2() {
		Logger.start(true,"多商品-都按重量-同模版-商品累加-重量和金额都为小时【A商品3.7KG,B商品4.1KG-模版:首1.5KG2.1元,每增2.3KG2.6元,返回运费  2.1+【(7.8-1.5)/2.3】*2.6=9.9(A商品:少于1倍续增,按2倍续增,B商品:少于2倍续增,按2倍续增  )】");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1.5"),new BigDecimal("2.1"),new BigDecimal("2.3"),new BigDecimal("2.6"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("3.7"));
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("4.1"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("9.9");//总运费

		    BigDecimal rate=new BigDecimal("3.7").divide(new BigDecimal("7.8"),  10, RoundingMode.DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, RoundingMode.DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, RoundingMode.DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_021() {
		Logger.start(true,"多商品-计费方式不同-不同模版-商品累加【A商品1件,模版1:首1件2元,每增1件2元,"
				+ "B商品2KG-模版2:首1KG2元,每1KG3元,返回运费A商品=2,B商品=5,一共7(A商品:默认运费 2,B商品:2倍续重2+【(3-1)/3】*2=5)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			//设置
			
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),2,sellerId).getLeft();
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(new BigDecimal(2));
			freightLst.add(new BigDecimal(5));
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_022() {
		Logger.start(true,"多商品-计费方式不同-不同模版-商品累加【A商品3件,模版1:首3件2元,每增1件2元,"
				+ "B商品6KG-模版2:首4KG2元,每2KG3元,返回运费A商品=2,B商品=5,一共7(A商品:默认运费 2,B商品:1倍续重2+【(6-4)/3】*2=5)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("4"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("3"),2,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("6"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(new BigDecimal(2));
			freightLst.add(new BigDecimal(5));
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_023() {
		Logger.start(true,"多商品-都按件-不同模版-商品累加【A商品1件,模版1:首1件2元,每增1件2元,"
				+ "B商品4件-模版2:首3件2元,每1件3元,返回运费A商品=2,B商品=5,一共7(A商品:默认运费2,B商品:2倍续重2+【(4-3)/1】*3=5)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(4);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(new BigDecimal(2));
			freightLst.add(new BigDecimal(5));
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_024() {
		Logger.start(true,"多商品-都按件-不同模版-商品累加【A商品4件,模版1:首4件1元,每增1件2元,"
				+ "B商品8件-模版2:首6件3元,每5件4元,返回运费A商品=1,B商品=7,一共8(A商品:默认运费2,B商品:少于1倍续增重,按1倍续增重3+【(8-6)/5】*4=7)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("4"),new BigDecimal("1"),new BigDecimal("1"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("6"),new BigDecimal("3"),new BigDecimal("5"),new BigDecimal("4"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(4);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(8);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("8");//总运费
			freightLst.add(new BigDecimal(1));
			freightLst.add(new BigDecimal(7));
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_025() {
		Logger.start(true,"多商品-都按件-不同模版-商品累加【A商品1件,模版1:首1件5元,每增1件6元,"
				+ "B商品4件-模版2:首1件7元,每2件8元,返回运费A商品=5,B商品=23,一共28(A商品:默认运费 2元,B商品:少于2倍续增重,按2倍续增重7+【(4-1)/2】*8=23)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("5"),new BigDecimal("1"),new BigDecimal("6"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("7"),new BigDecimal("2"),new BigDecimal("8"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(4);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("28");//总运费
			freightLst.add(new BigDecimal(5));
			freightLst.add(new BigDecimal(23));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_026() {
		Logger.start(true,"多商品-都按件-不同模版-商品累加【A商品4件,模版1:首3件2元,每增2件3元,"
				+ "B商品8件-模版2:首5件4元,每2件5元,返回运费A商品=5,B商品=14,一共19(A商品:少于1倍续增2+【(4-3)/2】*3=5,B商品:少于2倍续增重,按2倍续增重)3+【(8-5)/2】*5=14】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("3"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("5"),new BigDecimal("4"),new BigDecimal("2"),new BigDecimal("5"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(4);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(8);//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("19");//总运费
			freightLst.add(new BigDecimal(5));
			freightLst.add(new BigDecimal(14));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_027() {
		Logger.start(true,"多商品-都按件-不同模版-商品累加【A商品6件,模版1:首3件2元,每增2件2元,"
				+ "B商品5件-模版2:首2件2元,每2件2元,返回运费A商品=6,B商品=6,一共12(A商品:少于2倍续增,按2倍续增2+【(6-3)/2】*2=6,B商品:少于2倍续增重,按2倍续增重)2+【(5-2)/2】*2=6】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),new BigDecimal("2"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(6);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(5);//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("12");//总运费
			freightLst.add(new BigDecimal(6));
			freightLst.add(new BigDecimal(6));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_028() {
		Logger.start(true,"多商品-组合运算-单位相同【A商品2KG,模版1:首1KG10元,每增2KG5元,"
				+ "B商品3KG-模版2:首2KG12元,每3KG5元,返回运费22(首件/首重金额最大的运费模板,计算使用该模板的所有商品运费 模版2首重最大 B商品首重加续重:12+【(3-2)/3】*5)】=17 + A商品续重【2/3】*5=5)");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("10"),new BigDecimal("2"),new BigDecimal("5"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("12"),new BigDecimal("3"),new BigDecimal("5"),2,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("3"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("22");//总运费
			freightLst.add(new BigDecimal(5));
			freightLst.add(new BigDecimal(17));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_029() {
		Logger.start(true,"多商品-组合运算-单位不同【A商品3件,模版1:首2件10元,每增2件7元,B商品3KG-模版2:首2KG12元,每3KG4元,返回运费30(首件/首重金额最大的运费模板,计算使用该模板的所有商品运费 "
				+ "模版2首重最大 B商品首重加续重:12+【(3-2)/3】*4)】=16 + A商品续重【3/2】*7=14)");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("10"),new BigDecimal("2"),new BigDecimal("7"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("12"),new BigDecimal("3"),new BigDecimal("4"),2,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setQuantity(3);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("3"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("30");//总运费
			freightLst.add(new BigDecimal(14));
			freightLst.add(new BigDecimal(16));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_030() {
		Logger.start(true,"多商品-组合运算【A商品5KG,模版1:首3KG15元,每增1KG10元,B商品5KG-模版2:首1KG15元,每1KG5元,返回运费85(两个模版默认运费一样,总运费一样,分别把其中一个最为首重,另外作为续重,取值大的 "
				+ "模版1作为首重:A商品 首重加续重15+【(5-3)/1】)】*10=35 B商品续重：5/1 *5=25  "
				+ "模版2作为首重:B商品首重加续重 15+【(5-1)/1】*5=15+20=35 A商品续重：(5/1)*10=50  故 模版2作为首重模版值最大 85");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("5"),2,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("5"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("85");//总运费
			freightLst.add(new BigDecimal(50));
			freightLst.add(new BigDecimal(35));
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_031() {
//		Logger.start(true,"多商品-组合运算【A商品5KG,模版1:首2KG件10元,每增1KG1元,B商品5KG-模版2:首2KG6元,每0.5KG6元,返回运费15(分别取模版最大首重)】");
		Logger.start(true,"多商品-组合运算【A商品5KG,模版1:首1KG10元,每增2KG10元,"
				+ "B商品5KG-模版2:首0.5KG6元,每2KG6元,返回运费48(分别取模版最大首重,不看单位值大小,A商品首重+续重：10+【(5-1)/2】*10=30 B商品续重：(【5/2】*6=18)");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("10"),new BigDecimal("2"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("0.5"),new BigDecimal("6"),new BigDecimal("2"),new BigDecimal("6"),2,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("5"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("48");//总运费
			freightLst.add(new BigDecimal(30));
			freightLst.add(new BigDecimal(18));
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_032() {
		Logger.start(true,"多商品-组合运算【A商品5KG,模版1:首3KG15元,每增1KG10元,B商品5件-模版2:首1件15元,每1件5元,返回运费85(两个模版默认运费一样,单位不一致)】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("5"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(5);//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("85");//总运费
			freightLst.add(new BigDecimal(50));
			freightLst.add(new BigDecimal(35));
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_033() {
		Logger.start(true,"多商品-同一模版-组合运算【A商品5KG,B商品2KG,模版1:首3KG15元,每增4KG10元,返回运费25(按累加运算)15+【(5+2-3)/4】*10=25】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("15"),new BigDecimal("4"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			//int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("5"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId1);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("25");//总运费

		    BigDecimal rate=new BigDecimal("5").divide(new BigDecimal("7"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_033_1() {
		Logger.start(true,"多商品-同一模版-组合运算【A商品5件,B商品2件,模版1:首3件15元,每增4件10元,返回运费25(按累加运算)15+【(5+2-3)/4】*10=25】");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("15"),new BigDecimal("4"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);//设置多运费模板计费方式
			//int templateId2=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("15"),new BigDecimal("1"),new BigDecimal("5"),1,sellerId).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setQuantity(5);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId1);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("25");//总运费

		    BigDecimal rate=new BigDecimal("5").divide(new BigDecimal("7"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_034() {
		Logger.start(true,"正例-saleMode销售方式为共享- 商品累加【商品1件,模版:首1件2元,每增1件2元,返回运费2(首运费)】 (1-直销 2-代理 3-共享,只要有3 共享，这个商家下不会有1和2)");
		try {
			//添加创建模版
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),1,2);
			
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getMainFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstNum(1);//首件数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("2"));//续件数2
//			createFreightDetailDto.setAddNum(1);//续增件
//			createFreightDetailDto.setAddFee(new BigDecimal("2"));//续增费	
//			int templateId1 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
//			
//			GodfreightmgrService.SetFreightCalcModel(createBean.getSellerId(), 1);//设置多运费模板计费方式
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setSaleMode(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);	
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_037() {
		Logger.start(true,"正例-包邮(templateId1=0)");
		try {
			//添加创建模版
			//Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(0);
			
			bean.setOrderDtos(orderList);
			//bean.setDeliveryCity("北京");
			call.setData(bean);
			call.callService();		
			
			//断言
			OrderDto exp_order=call.getOrderDtos().getOrderDtos().get(0);
			Logger.verifyEquals("true", call.getSuccess(), "验证返回Success成功");	
			Logger.verifyEquals("0", exp_order.getfreight().toString(), "验证返回OrderDto中的freight字段");//总运费
			
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CalcOrderFreight_040() {
		Logger.start(false,"反例-orderNo在订单列表中不是唯一的,目前没有做校验，前端调用做校验");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("15"),new BigDecimal("4"),new BigDecimal("10"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setQuantity(5);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId1);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));//数量/重量
			
			List<OrderDto> orderList2=setCalcOrderFreight(templateId1);
			
			OrderDto orderDto2=orderList2.get(0);
			orderDto2.setOrderNo(Integer.parseInt(TestDataManager.getRandomNum(5)));
			orderDto2.getProductDtos().add(productDto2.get(0));
			orderList.add(orderDto2);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CalcOrderFreight_053() {
		Logger.start(true,"正例-多个相同订单,目前没有做校验，前端调用做校验");
		try {
			//TODO 补全case代码
			org.junit.Assert.fail();
			
			call.setData(bean);
			call.callService();	
	
			Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");		
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_041() {
		Logger.start(false,"反例-sellerId为空");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).setSellerId(0);
			
			bean.setOrderDtos(orderList);
			//bean.setDeliveryCity("北京");
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_042() {
		Logger.start(false,"反例-productDtos订单中商品列表为null");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).setProductDtos(null);
			
			bean.setOrderDtos(orderList);
			//bean.setDeliveryCity("北京");
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_043() {
		Logger.start(false,"反例-productId为空");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setproductId(null);
			
			bean.setOrderDtos(orderList);
			//bean.setDeliveryCity("北京");
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");		
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_044() {
		Logger.start(false,"反例-catalogId规格Id为空");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setCatalogId(null);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");			
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_045() {
		Logger.start(false,"反例-quantity购买数量为0");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setQuantity(0);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");		
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_046() {
		Logger.start(false,"反例-saleMode销售方式不存在 为0");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setSaleMode(0);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
		   //断言
		   Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");
		   Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");			
		
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_050() {
		//Logger.start(true,"反例-首重为0，续重为0");
		Logger.start(true,"正例-商品3KG,模版：首重3KG0元，续重为4KG5元");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("0"),new BigDecimal("4"),new BigDecimal("5"),2);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("3"));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
		    //断言
			OrderDto exp_order=call.getOrderDtos().getOrderDtos().get(0);
			Logger.verifyEquals("true", call.getSuccess(), "验证返回Success成功");	
			Logger.verifyEquals("0", exp_order.getfreight().toString(), "验证返回OrderDto中的freight字段");	
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_050_1() {
		//Logger.start(true,"反例-首重为0，续重为0");
		Logger.start(true,"正例-商品5KG,模版：首重3KG6元，续重为4KG0元");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("6"),new BigDecimal("4"),new BigDecimal("0"),2);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("5"));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
		    //断言
			OrderDto exp_order=call.getOrderDtos().getOrderDtos().get(0);
			Logger.verifyEquals("true", call.getSuccess(), "验证返回Success成功");	
			Logger.verifyEquals("6", exp_order.getfreight().toString(), "验证返回OrderDto中的freight字段");	
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_051() {
		Logger.start(true,"反例-商品重量没有值，按重量计费-返回首重");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("6"),new BigDecimal("4"),new BigDecimal("0"),2);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setperWeight(null);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
		    //断言
			OrderDto exp_order=call.getOrderDtos().getOrderDtos().get(0);
			Logger.verifyEquals("true", call.getSuccess(), "验证返回Success成功");	
			Logger.verifyEquals("6", exp_order.getfreight().stripTrailingZeros().toPlainString(), "验证返回OrderDto中的freight字段");	
			
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_052() {
		Logger.start(true,"反例-商品件数没有值，按件计算运费-返回首件费用");
		try {
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setCreateFreightTemplate(new BigDecimal("3"),new BigDecimal("6"),new BigDecimal("4"),new BigDecimal("0"),2);
			int templateId1=templateIdAndSellerId.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setQuantity(0);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
		    //断言
			Logger.verifyEquals("false", call.getSuccess(), "验证返回Success成功");	
			Logger.verifyEquals("1", call.getErrorCode(), "验证返回ErrorCode成功");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_054() {
		Logger.start(true,"第一个商品分摊运费抹掉两位小数后的值-多商品-都按件-同模版-商品累加【A商品2.2KG,B商品11.2KG-模版:首2KG3元,每增3KG4元,返回运费3+【(13.2-2)/3】*4=19元,一共19(A商品:首运费 3元,B商品:续增件3倍 )】");
		try {
			
			//org.junit.Assert.fail();
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("2"),new BigDecimal("3"),new BigDecimal("3"),new BigDecimal("4"),2).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2"));
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("11.2"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			//orderList.add(orderList.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("19");//总运费

		    BigDecimal rate=new BigDecimal("2").divide(new BigDecimal("13.2"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);//约等于2.878787 去掉两个小数后  等于2.87
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_055() {
		Logger.start(true,"单商品-按件-商品累加-使用代理模版【商品4件,模版:首5件6元,每增7件8元,返回运费6(首运费)】");
		try {
			//添加创建模版
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),1,1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstNum(5);//首件数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("6"));//续件数2
//			createFreightDetailDto.setAddNum(7);//续增件
//			createFreightDetailDto.setAddFee(new BigDecimal("8"));//续增费
//			Integer templateId =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
			
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("5"),new BigDecimal("6"),new BigDecimal("7"),new BigDecimal("8"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1); 
			orderList.get(0).getProductDtos().get(0).setQuantity(4);
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//代理模版
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("6");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_056() {
		Logger.start(true,"单商品-按重量-商品累加-使用代理模版【商品6KG,模版:首4KG5元,每增3KG2元,返回运费7(小于一倍运费)】");
		try {
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),2,1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstWeight(new BigDecimal("4"));//首重数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("5"));//首续数量
//			createFreightDetailDto.setAddWeight(new BigDecimal("3"));//首重运费
//			createFreightDetailDto.setAddFee(new BigDecimal("2"));// 续重 运费
//			Integer templateId =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("4"),new BigDecimal("5"),new BigDecimal("3"),new BigDecimal("2"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("6"));
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//代理模版
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_057() {
		Logger.start(true,"多商品-都按件-同模版-商品累加-使用代理模版【A商品3件,B商品7件-模版:首2件5元,每增3件6元,返回运费5+【(9-2)/3】*6=23元,一共23(A商品:首运费 3元,B商品:小于2倍运费 )】");
		try {
		
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("2"),new BigDecimal("5"),new BigDecimal("3"),new BigDecimal("6"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品1件
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			//B商品3件
			List<ProductDto>  productDto2=this.setProduct(templateId1);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setQuantity(7);
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//代理模版
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("23");//总运费

		    BigDecimal rate=new BigDecimal("3").divide(new BigDecimal("10"),10, BigDecimal.ROUND_DOWN);//A商品平均数量
			BigDecimal freight1=rate.multiply(totalFreight).setScale(2, BigDecimal.ROUND_DOWN);
			BigDecimal freight2=totalFreight.subtract(freight1).setScale(2, BigDecimal.ROUND_DOWN);
			freightLst.add(freight1);
			freightLst.add(freight2);
			check_verify(freightLst,totalFreight);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_058() {
		Logger.start(true,"多商品-计费方式不同-不同模版-商品累加-使用代理模版【A商品3件,模版1:首4件5元,每增6件7元,"
				+ "B商品14KG-模版2:首3KG2元,每5KG3元,返回运费A商品=5,B商品=11,一共16(A商品:默认运费 5,B商品:大于2倍续重)】");
		try {
			//添加创建模版
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),1,1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstNum(4);//首件数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("5"));//续件数2
//			createFreightDetailDto.setAddNum(6);//续增件
//			createFreightDetailDto.setAddFee(new BigDecimal("7"));//续增费
//			int templateId1 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
//			
//			GodfreightmgrService.SetFreightCalcModel(createBean.getSellerId(), 1);
			//添加创建模版
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("4"),new BigDecimal("5"),new BigDecimal("6"),new BigDecimal("7"),1);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
//			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			
//			CreateFreightTemplateBean createBean2=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),2,1);
//			CreateFreightDetailDto createFreightDetailDto2=createBean2.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto2.setFirstWeight(new BigDecimal("3"));//首重数量
//			createFreightDetailDto2.setFirstFee(new BigDecimal("2"));//首续数量
//			createFreightDetailDto2.setAddWeight(new BigDecimal("5"));//首重运费
//			createFreightDetailDto2.setAddFee(new BigDecimal("3"));// 续重 运费
//			int templateId2 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean2));
			Pair<Integer, Integer>  templateIdAndSellerId2=this.setAgentFreightTemplate(new BigDecimal("3"),new BigDecimal("2"),new BigDecimal("5"),new BigDecimal("3"),2,sellerId);
			int templateId2=templateIdAndSellerId2.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 1);
			
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("14"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//A商品 代理模版
			orderList.get(0).getProductDtos().get(1).setSaleMode(2);//B商品代理模版
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("16");//总运费
			freightLst.add(new BigDecimal(5));
			freightLst.add(new BigDecimal(11));
			check_verify(freightLst,totalFreight);				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_059() {
		Logger.start(true,"多商品-组合运算-单位相同-使用代理模版【A商品2KG,模版1:首2KG8元,每增2KG5元,"
				+ "B商品3KG-模版2:首2KG11元,每3KG5元,返回运费22(首件/首重金额最大的运费模板,计算使用该模板的所有商品运费 模版2首重最大 B商品首重加续重:11+【(3-2)/3】*5)】=16 + A商品续重【2/3】*5=5)");
		try {
			//添加创建模版
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),2,1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstWeight(new BigDecimal("1"));//首重数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("10"));//首续数量
//			createFreightDetailDto.setAddWeight(new BigDecimal("2"));//首重运费
//			createFreightDetailDto.setAddFee(new BigDecimal("5"));// 续重 运费
//			int templateId1 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
//			
//			GodfreightmgrService.SetFreightCalcModel(createBean.getSellerId(), 2);//设置多运费模板计费方式
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("1"),new BigDecimal("10"),new BigDecimal("2"),new BigDecimal("5"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);
			
//			CreateFreightTemplateBean createBean2=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),2,1);
//			CreateFreightDetailDto createFreightDetailDto2=createBean2.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto2.setFirstWeight(new BigDecimal("2"));//首重数量
//			createFreightDetailDto2.setFirstFee(new BigDecimal("11"));//首续数量
//			createFreightDetailDto2.setAddWeight(new BigDecimal("3"));//首重运费
//			createFreightDetailDto2.setAddFee(new BigDecimal("5"));// 续重 运费
//			int templateId2 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean2));
			Pair<Integer, Integer>  templateIdAndSellerId2=this.setAgentFreightTemplate(new BigDecimal("2"),new BigDecimal("11"),new BigDecimal("3"),new BigDecimal("5"),2);
			int templateId2=templateIdAndSellerId2.getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setperWeight(new BigDecimal("2"));//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("3"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//A商品 代理模版
			orderList.get(0).getProductDtos().get(1).setSaleMode(2);//B商品代理模版
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("21");//总运费
			freightLst.add(new BigDecimal(5));
			freightLst.add(new BigDecimal(16));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_060() {
		Logger.start(true,"多商品-组合运算-单位不同-使用代理模版【A商品2件,模版1:首3件4元,每增5件6元,B商品4KG-模版2:首2KG8元,每9KG10元,返回运费24(首件/首重金额最大的运费模板,计算使用该模板的所有商品运费 "
				+ "模版2首重最大 B商品首重加续重:8+【(4-2)/9】*10)】=18 + A商品续重【2/5】*6=6)");
		try {
			//添加创建模版
//			CreateFreightTemplateBean createBean=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),1,1);
//			CreateFreightDetailDto createFreightDetailDto=createBean.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto.setFirstNum(3);//首件数量
//			createFreightDetailDto.setFirstFee(new BigDecimal("4"));//续件数2
//			createFreightDetailDto.setAddNum(5);//续增件
//			createFreightDetailDto.setAddFee(new BigDecimal("6"));//续增费	
//			int templateId1 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean));
			
//			GodfreightmgrService.SetFreightCalcModel(createBean.getSellerId(), 2);//设置多运费模板计费方式
			Pair<Integer, Integer>  templateIdAndSellerId=this.setAgentFreightTemplate(new BigDecimal("3"),new BigDecimal("4"),new BigDecimal("5"),new BigDecimal("6"),2);
			int sellerId=templateIdAndSellerId.getRight();
			int templateId1=templateIdAndSellerId.getLeft();
			GodfreightmgrService.SetFreightCalcModel(sellerId, 2);
			
//			CreateFreightTemplateBean createBean2=GodfreightmgrService.initCreateFreightTemplate(Integer.parseInt(TestDataManager.getRandomNum(5)),2,1);
//			CreateFreightDetailDto createFreightDetailDto2=createBean2.getAgentFreight().getTemplateItems().get(0);//代理模版
//			createFreightDetailDto2.setFirstWeight(new BigDecimal("2"));//首重数量
//			createFreightDetailDto2.setFirstFee(new BigDecimal("8"));//首续数量
//			createFreightDetailDto2.setAddWeight(new BigDecimal("9"));//首重运费
//			createFreightDetailDto2.setAddFee(new BigDecimal("10"));// 续重 运费
//			int templateId2 =Integer.parseInt(GodfreightmgrService.CreateFreightTemplate(createBean2));
			Pair<Integer, Integer>  templateIdAndSellerId2=this.setAgentFreightTemplate(new BigDecimal("2"),new BigDecimal("8"),new BigDecimal("9"),new BigDecimal("10"),2);
			int templateId2=templateIdAndSellerId2.getLeft();
			
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).setSellerId(sellerId);
			orderList.get(0).getProductDtos().get(0).setQuantity(2);//数量/重量
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("4"));//数量/重量
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			orderList.get(0).getProductDtos().get(0).setSaleMode(2);//A商品 代理模版
			orderList.get(0).getProductDtos().get(1).setSaleMode(2);//B商品代理模版
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("24");//总运费
			freightLst.add(new BigDecimal(6));
			freightLst.add(new BigDecimal(18));
			check_verify(freightLst,totalFreight);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_061() {
		Logger.start(true,"单商品-按件-商品累加【商品1件,模版:首1件2元,每增1件2元,返回运费2(首运费)】-外币币种校验-RMB");
		try {
			List<EditFreightTemplateBean> templatelist=new ArrayList<EditFreightTemplateBean>();
			CreateFreightTemplateBean createBean = initCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			createBean.setCurrency("CNY");
			String templateId =GodfreightmgrService.CreateFreightTemplate(createBean);
			EditFreightTemplateBean ebean=GodfreightmgrService.initEditFreightTemplateBean(createBean, Integer.valueOf(templateId));
			templatelist.add(ebean);
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(Integer.valueOf(templateId));
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);
			call.getOrderDtos().orderDtos.forEach(od->{
				//验证templateId的Currency
				templatelist.forEach(t->{	
					od.getProductDtos().stream().filter(pd->{return pd.getTemplateId().equals(t.getTemplateId());}).forEach(pd->{
						Logger.comment("验证template:"+t.getTemplateId()+":的Currency:"+t.getCurrency());
						Logger.verifyEquals(t.getCurrency(), pd.getFreightCurrency(), "验证Currency");
						});
					});
			});;
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_062() {
		Logger.start(true,"单商品-按件-商品累加【商品1件,模版:首1件2元,每增1件2元,返回运费2(首运费)】-外币币种校验-USD");
		try {
			List<EditFreightTemplateBean> templatelist=new ArrayList<EditFreightTemplateBean>();
			CreateFreightTemplateBean createBean = initCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			createBean.setCurrency("USD");
			String templateId =GodfreightmgrService.CreateFreightTemplate(createBean);
			EditFreightTemplateBean ebean=GodfreightmgrService.initEditFreightTemplateBean(createBean, Integer.valueOf(templateId));
			templatelist.add(ebean);
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(Integer.valueOf(templateId));
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);
			call.getOrderDtos().orderDtos.forEach(od->{
				//验证templateId的Currency
				templatelist.forEach(t->{	
					od.getProductDtos().stream().filter(pd->{return pd.getTemplateId().equals(t.getTemplateId());}).forEach(pd->{
						Logger.comment("验证template:"+t.getTemplateId()+":的Currency:"+t.getCurrency());
						Logger.verifyEquals(t.getCurrency(), pd.getFreightCurrency(), "验证Currency");
						});
					});
			});;
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_063() {
		Logger.start(true,"多商品-都按件-不同模版-外币币种校验-不同货币");
		try {
			List<EditFreightTemplateBean> templatelist=new ArrayList<EditFreightTemplateBean>();
			CreateFreightTemplateBean createBean = initCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("2"),1);
			createBean.setCurrency("USD");
			Integer templateId1 =Integer.valueOf(GodfreightmgrService.CreateFreightTemplate(createBean));
			EditFreightTemplateBean ebean=GodfreightmgrService.initEditFreightTemplateBean(createBean, templateId1);
			templatelist.add(ebean);
			GodfreightmgrService.SetFreightCalcModel(createBean.getSellerId(), 1);//设置多运费模板计费方式
			
			CreateFreightTemplateBean createBean2 = initCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("3"),2);
			createBean2.setCurrency("CNY");
			createBean2.setSellerId(createBean.getSellerId());
			Integer templateId2 =Integer.valueOf(GodfreightmgrService.CreateFreightTemplate(createBean2));
			EditFreightTemplateBean ebean2=GodfreightmgrService.initEditFreightTemplateBean(createBean2, templateId2);
			templatelist.add(ebean2);
			List<OrderDto> orderList=setCalcOrderFreight(templateId1);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			//B商品
			List<ProductDto>  productDto2=this.setProduct(templateId2);
			productDto2.get(0).setproductId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setCatalogId(TestDataManager.getRandomNum(5));
			productDto2.get(0).setperWeight(new BigDecimal("2"));
			orderList.get(0).getProductDtos().add(productDto2.get(0));
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("7");//总运费
			freightLst.add(new BigDecimal(2));
			freightLst.add(new BigDecimal(5));
			check_verify(freightLst,totalFreight);				
			
			call.getOrderDtos().orderDtos.forEach(od->{
				//验证templateId的Currency
				templatelist.forEach(t->{	
					od.getProductDtos().stream().filter(pd->{return pd.getTemplateId().equals(t.getTemplateId());}).forEach(pd->{
						Logger.comment("验证template:"+t.getTemplateId()+":的Currency:"+t.getCurrency());
						Logger.verifyEquals(t.getCurrency(), pd.getFreightCurrency(), "验证Currency");
						});
					});
			});;
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_064() {
		Logger.start(true,"单商品-按件-商品累加-首件金额为0-【商品1件,模版:首1件0元,每增1件2元,返回运费0(首运费)】-JIRACONN-31975");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("0"),new BigDecimal("1"),new BigDecimal("2"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("0");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_065() {
		Logger.start(true,"单商品-按件-商品累加-续件金额为0-【商品1件,模版:首1件2元,每增1件0元,返回运费2(续运费)】-JIRACONN-31975");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("0"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(3);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_066() {
		Logger.start(true,"单商品-按件-商品累加-续件金额为0，但计算的是首重,返回首重金额-【商品1件,模版:首1件2元,每增1件0元,返回运费2(首运费)】-JIRACONN-31975");
		try {
			//添加创建模版
			int templateId=this.setCreateFreightTemplate(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("1"),new BigDecimal("0"),1).getLeft();
			//设置
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			call.setData(bean);
			call.callService();		
			
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("2");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_067() {
		Logger.start(true,"多商品-送达城市在模版规定的城市");
		try {
			CreateFreightTemplateBean createfreighttemplateBean=new CreateFreightTemplateBean();
			CreateFreightTemplateCall createfreighttemplateCall=new CreateFreightTemplateCall();
			
			createmchBean createmchBean = GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			createfreighttemplateBean = GodfreightmgrService.initCreateFreightTemplate(createmchBean.getMchId(),1,2);

			CreateFreightDto createFreightDto = new CreateFreightDto();
			int calcModel = 1;
			createFreightDto.setCalcModel(calcModel);
			CreateFreightDetailDto createFreightDetailDto1 = setCreateFreightDetailDto(calcModel);
			createFreightDetailDto1.setDeliveryRegion(Arrays.asList("江苏省","浙江省","上海市"));
			createFreightDetailDto1.setFirstNum(1);
			createFreightDetailDto1.setFirstFee(new BigDecimal(1));
			createFreightDetailDto1.setAddFee(new BigDecimal(2));
			createFreightDetailDto1.setAddNum(5);
			List<CreateFreightDetailDto> templateItems = new ArrayList<>();
			templateItems.add(createFreightDetailDto1);
			templateItems.add(createfreighttemplateBean.getMainFreight().getTemplateItems().get(0));
			createfreighttemplateBean.getMainFreight().setCalcModel(1);
			createfreighttemplateBean.getMainFreight().setTemplateItems(templateItems);

			createfreighttemplateCall.setData(createfreighttemplateBean);
			createfreighttemplateCall.callService();
			
			int templateId = createfreighttemplateCall.getJsonObject().get("data").getAsJsonObject().get("templateId").getAsInt();
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			bean.setDeliveryCity("上海市");
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("1");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CalcOrderFreight_068() {
		Logger.start(true,"多商品-送达城市不在模版规定的城市");
		try {
			CreateFreightTemplateBean createfreighttemplateBean=new CreateFreightTemplateBean();
			CreateFreightTemplateCall createfreighttemplateCall=new CreateFreightTemplateCall();
			
			createmchBean createmchBean = GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			createfreighttemplateBean = GodfreightmgrService.initCreateFreightTemplate(createmchBean.getMchId(),1,2);

			CreateFreightDto createFreightDto = new CreateFreightDto();
			int calcModel = 1;
			createFreightDto.setCalcModel(calcModel);
			CreateFreightDetailDto createFreightDetailDto1 = setCreateFreightDetailDto(calcModel);
			createFreightDetailDto1.setDeliveryRegion(Arrays.asList("江苏省","浙江省","上海市"));
			createFreightDetailDto1.setFirstNum(1);
			createFreightDetailDto1.setFirstFee(new BigDecimal(1));
			createFreightDetailDto1.setAddFee(new BigDecimal(2));
			createFreightDetailDto1.setAddNum(5);
			List<CreateFreightDetailDto> templateItems = new ArrayList<>();
			templateItems.add(createFreightDetailDto1);
			templateItems.add(createfreighttemplateBean.getMainFreight().getTemplateItems().get(0));
			createfreighttemplateBean.getMainFreight().setCalcModel(1);
			createfreighttemplateBean.getMainFreight().setTemplateItems(templateItems);

			createfreighttemplateCall.setData(createfreighttemplateBean);
			createfreighttemplateCall.callService();
			
			int templateId = createfreighttemplateCall.getJsonObject().get("data").getAsJsonObject().get("templateId").getAsInt();
			List<OrderDto> orderList=setCalcOrderFreight(templateId);
			//A商品
			orderList.get(0).getProductDtos().get(0).setQuantity(1);
			
			bean.setOrderDtos(orderList);
			bean.setDeliveryCity("安徽省");
			call.setData(bean);
			call.callService();		
			//断言
			List<BigDecimal> freightLst=new ArrayList();
			BigDecimal totalFreight=new BigDecimal("10");//总运费
			freightLst.add(totalFreight);
			check_verify(freightLst,totalFreight);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	public CreateFreightDetailDto setCreateFreightDetailDto(int calcModel){
		CreateFreightDetailDto createFreightDetail = new CreateFreightDetailDto();
		createFreightDetail.setDefaultTemplate(false);//是否默认运费模板
		List<String> deliveryRegion = new ArrayList<>();
		deliveryRegion.add("啊啊啊");
		createFreightDetail.setDeliveryRegion(deliveryRegion);

		if (calcModel == 1){
			createFreightDetail.setFirstNum(1);//首件重量
			createFreightDetail.setAddNum(2);//续件重量
			createFreightDetail.setFirstFee(new BigDecimal(10));//首件/首重运费
			createFreightDetail.setAddFee(new BigDecimal(5));//续件 / 续重 运费
		}else if (calcModel == 2){
			createFreightDetail.setFirstWeight(new BigDecimal(1));//首件重量
			createFreightDetail.setAddWeight(new BigDecimal(2));//续件重量
			createFreightDetail.setFirstFee(new BigDecimal(15));//首件/首重运费
			createFreightDetail.setAddFee(new BigDecimal(10));//续件 / 续重 运费
		}
		return createFreightDetail;
	}
}